//
//  WYPayMessageView.m
//  Boss
//
//  Created by admin on 2018/7/16.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYPayMessageView.h"

@interface WYPayMessageView()

@property (strong, nonatomic) IBOutlet UIImageView *stateImageView;
@property (strong, nonatomic) IBOutlet UILabel *titleLabel;



@property (strong, nonatomic) IBOutlet UIView *twoBtnView;
@property (strong, nonatomic) IBOutlet UIView *oneBtnView;
@property (strong, nonatomic) IBOutlet UIButton *leftBtn;

@property (strong, nonatomic) IBOutlet UIButton *rightBtn;

@property (strong, nonatomic) IBOutlet UIButton *singleBtn;
@property (strong, nonatomic) IBOutlet UILabel *messageLabel;



@end



@implementation WYPayMessageView

-(void)awakeFromNib
{
    [super awakeFromNib];
    self.userInteractionEnabled = YES;
    [self.whiteView setCornerRadius:5.f];
}



-(void)setAlertTitle:(NSString *)title
        attributeMsg:(NSString *)msg
           imageName:(NSString *)name
           btnTitles:(id)titles
{
    
    //内容
    self.titleLabel.text = title;
    [self.titleLabel sizeToFit];
    self.stateImageView.image = [UIImage imageNamed:name];
    self.messageLabel.text = msg;
    
    //问号
    //self.warnBtn.hidden = !show;
    
    //按钮
    if ([titles isKindOfClass:[NSArray class]]) {  //数组
        
        NSArray *array = (NSArray *)titles;
        if (array.count == 1) {
            self.twoBtnView.hidden = YES;
            self.oneBtnView.hidden = NO;
            [self.singleBtn setTitle:array.firstObject forState:UIControlStateNormal];
            
        } else if (array.count == 2){
            self.twoBtnView.hidden = NO;
            self.oneBtnView.hidden = YES;
            [self.leftBtn setTitle:array.firstObject forState:UIControlStateNormal];
            [self.rightBtn setTitle:array.lastObject forState:UIControlStateNormal];
        }
    } else if ([titles isKindOfClass:[NSString class]]){ //字符串
        self.twoBtnView.hidden = YES;
        self.oneBtnView.hidden = NO;
        [self.singleBtn setTitle:titles forState:UIControlStateNormal];
    }
}


- (IBAction)btnClicked:(UIButton *)sender {
    if (_delegate) {
        [_delegate alertView:self clickedButtonAtIndex:sender.tag];
    }
}





@end
